package com.ibm.util;

import java.util.HashMap;

/**
 * Created by telekinesis on 5/6/15.
 */
public class DebugUtil {
	public static String getStackTrace(){
		StackTraceElement[] stack = Thread.currentThread().getStackTrace();
		StringBuffer buffer = new StringBuffer();
		buffer.append("\n");
		for (StackTraceElement stackTraceElement : stack) {
			buffer.append("===== ");
			buffer.append(stackTraceElement);
			buffer.append("\n");
		}
		return buffer.toString();
	}
	
    public static <K,V> void printHashMap(HashMap<K, V> toBePrinted){
        for(K key: toBePrinted.keySet()){
            System.out.println("--------- key: " + key + " value: " + toBePrinted.get(key).toString());
        }
    }

    public static <K,V> String convertHashMapToDebugString(HashMap<K, V> toBePrinted){
        StringBuffer buffer = new StringBuffer();
        for(K key: toBePrinted.keySet()){
            buffer.append("--------- key: " + key + " value: " + toBePrinted.get(key).toString() + "\n");
        }
        return buffer.toString();
    }
}
